<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="refresh" content="10; URL=//rawfile/onBeforeUnloadTest.html">
<title>W3Cschool在线教程(w3cschool.cn)</title>
</head>
<body onbeforeunload="return myFunction()">
    <a href="http://www.w3cschool.cn">点击跳转到W3Cschool在线教程</a>
    <img src="icon.png" alt="icon" id="imgs">
</body>
<script>
    let ele=document.getElementById('imgs');
    let loadImage;
    ele.onload=function(){
        loadImage = ele.click();
    }
    function myFunction() {
        document.getElementById('imgs').click();
        return '我在这写点东西...';
    }
    function myRefresh() {
       window.location.reload();
    }
    function myNewPage() {
        window.location.replace('http://www.w3cschool.cn')
    }
    myFunction()
</script>
</html>